package com.nami.gate.middleware.mq.listener;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;

import com.nami.gate.cache.LocalChannelCache;
import com.nami.gate.external.basic.constants.DownTopicConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DownMsgCloseChannelConsumer extends AbstractConsumer {

    private static final Logger log = LoggerFactory.getLogger(DownMsgCloseChannelConsumer.class);

    @Override
    public void onMessage(byte[] body) {
        try {
            String bodyStr = new String(body, "UTF-8");
            TimeInterval timer = DateUtil.timer();
            LocalChannelCache.removeAll(bodyStr);
            if (timer.interval() > 500) {
                log.warn("[close-channel] userId:{}, use:{}ms", body, timer.interval());
            }
        } catch (Exception var3) {
            var3.printStackTrace();
            log.error("[down-login] 消费出现问题:{}", var3.getMessage());
        }
    }

    @Override
    public String getTopicName() {
        return DownTopicConst.CLOSE_CHANNEL_TOPIC;
    }

}


